package com.example.footballsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.footballsystem.entity.SeriesGame;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SeriesGameMapper extends BaseMapper<SeriesGame> {
    @Insert("insert into seriesgame(seriesID, Name,fieldID, personNum, InitiaorAccount, competitionSystem, createdate,selectedDate,description,state,logPath) VALUES (#{seriesID},#{name},#{fieldID},#{personNum},#{initiaorAccount},#{competitionSystem},#{createDate},#{selectedDate},#{description},#{state},#{logPath})")
    public Boolean addSeriesGame(SeriesGame seriesGame);
    @Select("select * from seriesgame")
    public List<SeriesGame> getAllSeriesGame();
    @Select("select * from seriesgame where seriesID=#{seriesID}")
    public SeriesGame getSeriesGame(int seriesID);
    @Select("select * from seriesgame where Name like #{info}")          //searchByName("%info%")
    public List<SeriesGame> searchByName(String info);
    @Select("select * from seriesgame where InitiaorAccount=#{account}")
    public List<SeriesGame> getSeriesGameByAccount(String account);
    @Delete("delete from seriesgame where seriesID=#{id}")
    public Boolean deleteSeriesGame(int id);
    @Select("select max(seriesID)  from seriesgame")
    public int getMaxID();
    @Select("select InitiaorAccount from seriesgame where seriesID=#{seriesID}")
    public String getHostAccount(int seriesID);
    @Update("update seriesgame set personNum=personNum+1 where seriesID=#{seriesID}")
    public Boolean addPersonNum(int seriesID);
    @Update("update seriesgame set state=#{newState} where seriesID=#{seriesID}")
    public Boolean updateState(int seriesID,String newState);

}
